import java.util.ArrayList;
import java.util.List;

public class Test {
    public static List<Integer> findAnagrams(String s, String p) {
        int[] hash1 = new int[26];
        int[] hash2 = new int[26];
        List<Integer> list = new ArrayList<>();

        for(int i =0 ; i < p.length();i++){
            char ch = s.charAt(i);
            hash1[ch-97] ++;
        }
        for(int left =0 ,right =0 ; right < s.length(); right++){
            char in = s.charAt(right);
            hash2[in-97]++;
            if(right - left +1 > p.length()){
                int out = hash2[left];
                hash2[left] --;
                left++;
            }
            if(chack(hash1,hash2)){
                list.add(left);
            }
        }
        return list;

    }
    public static boolean chack(int[] hash1, int[] hash2){
        for(int i =0 ;i < hash1.length ; i++){
            if(hash1[i] != hash2[i]){
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
     List<Integer> list =  findAnagrams("aa","bb");
        System.out.println(list);
    }
}
